#! /bin/bash

help_end() {
    echo "Usage: $0 [options] <files/dirs>"
    echo '       rm with a little bit more confirms.'
    exit 0
}

if [[ $# = 0 ]]; then
    help_end
fi

declare -a ALL ADDITIONAL_FLAG

for f in "$@"
do
    if [[ $f = -* ]]; then
        ADDITIONAL_FLAG+=("$f")
    else
        ALL+=("$f")
    fi
done

read -rp 'You want to exterminate some file(s)/dir(s), ARE YOU SURE? (Enter "Yes, I am sure" to confirm): ' confirm
if [[ $confirm = 'Yes, I am sure' ]]; then
    read -rp "Please confirm that you want ${#ALL[@]} file(s)/dir(s) to remove by entering this number: " second_confirm
    if [[ $second_confirm = "${#ALL[@]}" ]]; then
        read -rp "Please repeat the name of the first item (${ALL[0]}) to complete the final confirm: " third_confirm
        if [[ $third_confirm = "${ALL[0]}" ]]; then
            echo 'Annihilatation start!'
            rm "${ADDITIONAL_FLAG[@]}" "${ALL[@]}"
            exit 0
        fi
    fi
fi

echo 'Annihilatation canceled!'
